
execfile('v4/base.py')

class ZhishuF(Base):
    def __init__(self):
        self.bar_count_default = 50
        self.end_date_str = '20250831'  # 如果需要可以取消注释
        # self.start_date_str = '2025-06-16'  # 如果需要可以取消注释



    ''' 将dict转成Dataframe '''
    def dict_to_dataframe(self,origin_dict):
        # 创建一个空的DataFrame，用于存放最终结果
        result_df = pd.DataFrame()
        # 遍历字典，将每个DataFrame与股票代码和日期索引合并，并追加到result_df中
        for code, df in origin_dict.items():
            # 将索引（日期）和股票代码作为列添加到DataFrame中
            temp_df = df.reset_index().rename(columns={'index': 'date'})
            temp_df['code'] = code  # 添加股票代码列
            result_df = pd.concat([result_df, temp_df], ignore_index=True)  # 合并DataFrame
        return result_df
    
        
    def get_zhishu_raise_ma_df(self,zhishu_df):
        zhishu_raise_df = mark_raise(zhishu_df)
        zhishu_ma_df = mark_d_ma(zhishu_df)
        zhishu_dfs = [zhishu_raise_df, zhishu_ma_df,zhishu_df]
        zhishu_final = merge_df(zhishu_dfs)
        zhishu_final = zhishu_final.drop(columns='code')
    
        zhishu_final = zhishu_final.add_prefix('zs_')
        zhishu_final = zhishu_final.reset_index(drop=True).rename(columns={'zs_date':'date'})
        return zhishu_final
    
    
    
    def save_csv(df,name):
        df.to_csv('input/'+str(name),index=False,encoding='utf-8-sig')
